fix: eliminate -B double-dispatch through mock system#91
Draft
Koan-Bot wants to merge 1 commit intocpan-authors:mainfrom
Draft
fix: eliminate -B double-dispatch through mock system#91Koan-Bot wants to merge 1 commit intocpan-authors:mainfrom
Koan-Bot wants to merge 1 commit intocpan-authors:mainfrom
Conversation
The -B handler in _check_from_stat called `-d $f_or_fh` to check for directories, which re-entered the mock system and triggered a redundant second call to the user's stat callback. Replace with an inline mode-bit check on the already-cached @stat array. Also add B and T to the $can_use_stat set so they use stat (not lstat), matching Perl's symlink-following behavior for these operators. Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fix the
-Bhandler in_check_from_statto avoid re-entering the mock system.Why
The
-Bhandler called-d $f_or_fhto check if the target is a directory. Since-dis also mocked undermock_all_from_stat, this triggered a full second round-trip through the mock dispatch — calling the user's stat callback again. This is wasteful and risks inconsistency if the callback has side effects or returns different results on subsequent calls.Additionally,
-Band-Twere usinglstatinstead ofstat, which is incorrect — both operators follow symlinks in Perl.How
-d $f_or_fhwith an inline mode-bit check (_S_IFMTmask againstS_IFDIR) on the already-cached@statarray — zero mock re-entry.BandTto the$can_use_statcharacter class so the stat cache (not lstat) is used, matching Perl's symlink-following semantics.Testing
t/B-no-double-dispatch.tverifies the stat callback is called exactly once per-Bcheck (regular file, directory, non-existent file).🤖 Generated with Claude Code
Quality Report
Changes: 2 files changed, 63 insertions(+), 2 deletions(-)
Code scan: clean
Tests: passed (0 Tests)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline